﻿Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports MySql.Data.MySqlClient

Public Class frmTrocarSenha

    Private Sub btnSalvar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSalvar.Click
        Dim SCE As New MySqlConnection(My.MySettings.Default.SCE_ETEC_ConnectionString) 'Properties.Settings.[Default].SCE_ETEC_ConnectionString)
        Try
            'SqlConnection SCE = new MySqlConnection(Properties.Settings.Default.SCE_ETEC_ConnectionString);
            Dim cmd As New MySqlCommand()
            SCE.Open()

            ' comando UPDATE tabela SET campo1='valor', campo2='valor' WHERE id='valor'
            Dim sqlCmd As String = "UPDATE Login SET senha=@nova_senha WHERE usuario=@usuario"
            cmd = New MySqlCommand(sqlCmd, SCE)

            cmd.Parameters.AddWithValue("@usuario", frmLogin.usuario)
            cmd.Parameters.AddWithValue("@nova_senha", txtSenha.Text)

            cmd.ExecuteNonQuery()
            MsgBox("Concluido.", vbOKOnly, "Aviso")
        Catch erro As MySqlException
            MsgBox(erro.Message, vbOKOnly, "Erro")
        Finally
            SCE.Close()
            txtSenha.Clear()
        End Try
    End Sub
End Class